import React, { Component } from 'react';
import { ResultPage,Card } from 'antd-mobile'
import { AlipayCircleFill } from 'antd-mobile-icons'
import * as  service from '../api/index'
class Gopay extends Component {
    constructor(props){
        super(props)
        this.state={
            details : [
                {
                  label: '账户余额',
                  value: '$562310000',
                  bold: true,
                },
                {
                  label: '付款方式',
                  value: '中国建设银行',
                },
              ],
              money:''
        }
    }
    componentDidMount(){
       this.setState({money: this.props.location.state.money})
    }
     async onSecondaryButtonClick(){//支付成功删除购物车列表
         await service. order_deleteCartItem({userid:localStorage.getItem('userid')})
         this.props.history.push('/index/goodcar')
    }
    render() {
            return (

            <div className='gopay' >
                <ResultPage
                    status='waiting'
                    title={<div style={{ fontSize: 15 }}>支付成功</div>}
                    description={
                        <>
                            <span style={{ fontSize: 32, color: '#ffffff', marginRight: 4 }}>
                                ¥
                            </span>
                            <span style={{ fontSize: 48, color: '#ffffff' }}>{this.state.money}</span>
                        </>
                    }
                    icon={<AlipayCircleFill />}
                    details={this.state.details}
                    secondaryButtonText='返回'
                    primaryButtonText='确认订单'
                    onSecondaryButtonClick={()=>{this.onSecondaryButtonClick()}}
                    onPrimaryButtonClick={()=>{this.onSecondaryButtonClick()}}
                >
                    <Card style={{ height: 64 }}> </Card>
                    <Card style={{ height: 128, marginTop: 12 }}> </Card>
                </ResultPage>

            </div>
        );
    }
}

export default Gopay;